package com.mistyrain.service.impl;

import com.mistyrain.entity.Menu;
import com.mistyrain.entity.MenuVO;
import com.mistyrain.mapper.MenuMapper;
import com.mistyrain.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;
    @Override
    public MenuVO findAll(int page, int limit) {
        MenuVO menuVO = new MenuVO();
        menuVO.setCode(0);
        menuVO.setMsg("");
        menuVO.setCount(menuMapper.count());
        menuVO.setData(menuMapper.findAll((page-1)*limit,limit));
        return menuVO;
    }

    @Override
    public int count() {
        return menuMapper.count();
    }

    @Override
    public void save(Menu menu) {
        menuMapper.save(menu);
    }

    @Override
    public Menu findById(long id) {
        return menuMapper.findById(id);
    }

    @Override
    public void update(Menu menu) {
        menuMapper.update(menu);
    }

    @Override
    public void deleteById(long id) {
        menuMapper.deleteById(id);
    }
}
